<!-- 
All rights Reserved, Designed By www.youyacao.com 
@Description:代理注册页面
@author:成都市一颗优雅草科技有限公司     
@version 松鼠聚合直播系统v2.0
注意：本前端源码遵循 MulanPSL-2.0开源协议（木兰宽松许可证）本内容仅限于个人参考，禁止用于其他的商业用途
需要商业用途或者定制开发等可访问songshu.youyacao.com   联系QQ:422108995 23625059584

 -->


<template>
    <div class="login-box">
        <div class="login-title">代理注册</div>
        <div class="login-input">
            <van-field
                    v-model="username"
                    clearable
                    placeholder="输入需要注册的代理账号"
                    left-icon="manager"
            />

            <van-field
                    v-model="password"
                    type="password"
                    clearable
                    placeholder="输入复杂密码避免被破解"
                    left-icon="lock"
            />
            <van-field
                    v-model="repassword"
                    type="password"
                    clearable
                    placeholder="为保安全请再输一次密码"
                    left-icon="lock"
            />
            <van-field
                        v-model="yzcode"
                        clearable
                        left-icon="youzan-shield"
                        placeholder="输入代理激活码"
                />

        </div>
        <div class="button-box">
            <van-button type="primary" style="height: 40px;line-height: 40px; margin-bottom: 20px;" size="large" @click="onSubmitRegister" :disabled="disabled" :loading="disabled" loading-text="提交中...">立即注册</van-button>
            <van-button type="default" style="height: 40px;line-height: 40px;" size="large" to="/login">返回登陆</van-button>
        </div>
    </div>
</template>

<script>
    import global_ from '../Global';
    import { Toast } from 'vant';
    import { Dialog } from 'vant';
    export default {
        name: "register",
        data(){
          return {
              username:'',
              password:'',
              repassword:'',
              yzcode:'',
              disabled:false
          }
        },
        created:function(){
            window.loginInfo = null;
            this.$axios.get(global_.serverUrl+"admin/visitor/logout");
        },
        methods:{
            onSubmitRegister:function () {
                var that = this;
                this.disabled = true;
                this.$axios.post(global_.serverUrl+'admin/visitor/register',{
                    username:this.username,
                    password:this.password,
                    repassword:this.repassword,
                    yzcode:this.yzcode
                }).then(function (response) {
                    if(response.code != 1){
                        Toast(response.msg);
                    }else{
                        that.$router.replace({path:'/login'});
                        return;
                    }
                    that.disabled = false;
                    that.password = '';
                    that.repassword = '';
                }).catch(function (error) {
                    that.disabled = false;
                    that.password = '';
                    that.repassword = '';
                });
            }
        }
    }
</script>

<style scoped>
    .login-box{
        width: 300px;
        margin: 100px auto;
        background:#ffffff;
        padding: 20px;
        border-radius: 5px;
        border: 1px solid #cccccc;
        height: 400px;
    }
    .login-title{
        font-weight: bold;
        font-size: 20px;
        text-align: center;
        padding-bottom: 20px;
    }
    .login-input .van-cell{
        margin: 10px 0px;
    }
</style>
